package ru.gelin.android.keyboard;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.BitmapFactory;

/**
 *  The Notification which shows input method picker dialog (keyboard chooser)
 *  on clicking on it.
 */
public class ShowInputMethodPickerNotification {

    static final int ID = 0;

    private ShowInputMethodPickerNotification() {
        //avoid instantiation
    }

    private static Notification build(Context context) {
        return new Notification.Builder(context)
                .setContentTitle(context.getString(R.string.notification_title))
                .setContentText(context.getString(R.string.notification_text))
                .setSmallIcon(R.drawable.keyboard_w)
                .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.keyboard))
                .setOngoing(true)
                .setContentIntent(PendingIntent.getActivity(context, 0, Shortcut.getShowInputMethodPicketIntent(), 0))
                .getNotification();
    }

    public static void show(Context context) {
        NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        manager.notify(ID, build(context));
    }

    public static void hide(Context context) {
        NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        manager.cancel(ID);
    }

}
